app.controller('DataTableController', ['$scope', 'RESTService', 'RS', function($scope, RESTService, RS) {
	var accessurl = RS.protocol+RS.server+RS.port+RS.context+RS.restUrl
    	+"?"+RS.access_token+access_token;
	
    $scope.heroes = [
            {
                "patCase_Id": 1,
                "userId": 1,
                "brief_Desc": "骨头损伤",
                "waist_Pain": null,
                "main_Desc": "下肢骨头损伤",
                "blood_Pressure_High": 140,
                "blood_Pressure_Low": 90,
                "weight": 55,
                "height": 160,
                "body_Temp": 37,
                "heart_Beat": 79,
                "breath_Int": 44,
                "bmi": 32,
                "updated": 1461340800000,
                "lower_Limb": null,
                "lower_Limb_Muscle": null,
                "upper_Limb": null,
                "spirit_State": null,
                "strength": null,
                "appetite": null,
                "sleeping": null,
                "weight_Change": 0,
                "gatism_Handling": null,
                "method_Transport": null,
                "spine_Waist": null,
                "spine_Waist_Angle": 0,
                "spine_Skin": null,
                "spine_KnockPain": null,
                "spine_KnockPain_No": 0,
                "patient": {
                    "patient_Id": 1,
                    "userId": 5,
                    "history_Chem_Contact": null,
                    "history_Epidemic_Area": null,
                    "history_Live_Area": null,
                    "history_Drug": 1,
                    "history_Somoking": 0,
                    "history_Drink": 0,
                    "person_Menses": 0,
                    "child_Number": null,
                    "child_Health": null,
                    "history_Family": null,
                    "history_Epidemic_Disease": null,
                    "history_Diseases": null,
                    "history_Operation": null,
                    "history_Allergic": null,
                    "history_Vaccine": null,
                    "updated": 1461340800000,
                    "user": {
                        "userId": 5,
                        "userType_Id": 2,
                        "icCardFile": null,
                        "icNo": null,
                        "loginName": "patient_demo",
                        "gender": null,
                        "email": null,
                        "realName": "patient_demo",
                        "race_Id": 0,
                        "location_Country": 0,
                        "location_Province": 0,
                        "location_City": 0,
                        "location_County": 0,
                        "location_Town": 0,
                        "location_Address": null,
                        "marriage": null,
                        "telephone": null,
                        "mobile_Phone": null,
                        "emerg_Contact": null,
                        "emerg_Contact_Mobile": null,
                        "photo_File": null,
                        "updated": 1461340800000,
                        "userType": {
                            "userType_Id": 2,
                            "userType_Name": "User",
                            "userType_Desc": "Person who is a potential patient",
                            "updated": 1460701205193,
                            "doctor": false,
                            "assistant": false,
                            "normalUser": true
                        },
                        "doctor": null,
                        "race": null,
                        "province": null,
                        "city": null,
                        "county": null
                    }
                }
            }
        ];
    $scope.addPatient = function(){       //添加病人函数
    	alert($scope.heroes.length);
    	$scope.heroes.push({name:$scope.newName, id:$scope.newId, age:$scope.newAge, addr:$scope.newAddr});
    	$scope.newName='';
    	$scope.newId='';
    	$scope.newAge='';
    	$scope.newAddr='';
    	alert($scope.heroes.length);
    	angular.forEach($scope.heroes, function(data){
			console.log(data.name);
			});
    };
    
    $scope.deletePatient = function(index){   //删除选中的一行
    	//if($window.confirm("确定要删除该条信息?")) {
    		$scope.heroes.splice(index, 1);
    		angular.forEach($scope.heroes, function(data){
    			console.log(data.name);
    			});
    	//}
    };
    
    $scope.modifyPatient = function(index){
    	var item = $scope.heroes[index];
    	$scope.newName = item.name;
    	$scope.newId = item.id;
    	$scope.newAge = item.age;
    	$scope.newAddr = item.addr;
    	alert($scope.newName);
    };
    
}]);
 
